How to use `wx.ProgressDialog` with my own method?

Posted by user1401950 on Stack Overflow See other posts from Stack Overflow or by user1401950
Published on 2012-09-02T21:47:20Z Indexed on 2012/09/03 3:38 UTC
Read the original article Hit count: 95

Filed under:
|
|

How can I use the wx.ProgressDialog to time my method called imgSearch? The imgSearch method finds image files on the user's pc. How can I make the wx.ProgressDialog run while imgSearch is still running and display how long the imgSearch is taking?

Here's my code:

def onFind (self,event)# triggered by a button click
    max = 80
    dlg = wx.ProgressDialog("Progress dialog example","An informative message",parent=self, style = wx.PD_CAN_ABORT| wx.PD_APP_MODAL| wx.PD_ELAPSED_TIME| wx.PD_REMAINING_TIME)

    keepGoing = True
    count = 0
    imageExtentions = ['*.jpg', '*.jpeg', '*.png', '*.tif', '*.tiff']
    selectedDir = 'C:\\'
    imgSearch.findImages(imageExtentions, selectedDir)# my method

    while keepGoing and count < max:

    count += 1
    wx.MilliSleep(250)

    if count >= max / 2:
        (keepGoing, skip) = dlg.Update(count, "Half-time!")
    else:
        (keepGoing, skip) = dlg.Update(count)

    dlg.Destroy()

© Stack Overflow or respective owner

Related posts about python

Related posts about gui